doctype
html
    head
        title Backbone Model Test
        meta(http-equiv="Content-Type", content="text/html; charset=UTF-8")
        script(src="../../lib/jquery.min.js")
        script(src = "../../lib/underscore.js")
        script(src = "../../lib/backbone.js")
    body
        script(type='text/javascript').
            var UserModel = Backbone.Model.extend({
                urlRoot: '/user',
                defaults: {
                    name: '',
                    email: ''
                }
            });
            var user = new UserModel({id: 1});
            var userDetails = {
                name: 'Thomas',
                email: 'thomasalwyndavis@gmail.com'
            };
            user.save(userDetails, {
                success: function (user) {
                    alert(user.toJSON());
                },
                error: function (user) {
                    alert("save" + user.get("id"));
                }
            })

            var user2 = new UserModel();
            var userDetails = {
                id: 1,
                name: 'Thomas',
                email: 'thomasalwyndavis@gmail.com'
            };
            user2.destroy({
                success: function (user) {
                    alert("delete successfully");
                },
                error: function (user) {
                    alert("delete error " + user.get("id"));
                }
            })
